MySpoolProc
The QuickDraw GX functionsGXFlattenShape
andGXUnflattenShape
require the calling application to supply a pointer to a function that, respectively, saves flattened data or supplies data to be flattened. The flattening/unflattening spool function has the following interface:
long MySpoolProc(gxSpoolCommand command, struct gxSpoolBlock *block);
command
- A selector with which QuickDraw GX specifies the operation the spool function is to perform.
block
- A pointer to the spool block used for the current flattening or unflattening operation.
- function result
- Zero if the unflattening or flattening operation can continue; nonzero if QuickDraw GX must abort the operation.
DESCRIPTION
The purpose of the flattening/unflattening spool function is to move flattened data into or out of memory as instructed by QuickDraw GX. You place a pointer to the spool function in the appropriate field of the spool block structure that you allocate before callingGXFlattenShape
orGXUnflattenShape
.Your spool function should respond to the
command
parameter and perform the appropriate operation. Constants for the recognized spool commands are defined in thegxSpoolCommands
enumeration:Your spool function's function result is a status indicator to QuickDraw GX. If the operation must be aborted (for example, if a file error occurs), return a nonzero value as the function result. Otherwise, return 0 and the flattening or unflattening operation can continue.
For simple flattening and unflattening, your spool function need only read and write the amounts of data specified by QuickDraw GX. However, you can also write a spool function that actually parses the data stream during flattening and unflattening; see Listing 2-5 on page 2-41 for an example.
SPECIAL CONSIDERATIONS
During a flattening or unflattening procedure, a memory error can cause a restart of the function, which might not necessarily reset the stream back to its original position. Therefore, your open, read, and write routines must always be sure to set the stream to the correct position in the buffer each time.SEE ALSO
The spool block structure is described on page 2-49.The
GXFlattenShape
function is described on page 2-88. TheGXUnflattenShape
function is described on page 2-90.